#pragma once

#include "molecular_atom.h"
#include "models/atom_interface/ai_window_poker.h"

class WindowPoker :
    public M::Atom
{
public:
    WindowPoker();
    virtual ~WindowPoker();

    virtual M::String name() const { return PAN_WINDOW_POKER; }
    virtual bool OnExecute(const M::AtomEndPoint &oSrcAtom, int nFuncId, void *pParams, void *pIOParams);

protected:
    bool OnSetKeyState(PPKeyState *pParams);
    bool OnGetKeyState(PPKeyState *pParams);
    bool OnSendKeyMessage(PPSendKeyMessage *pParams);
    bool OnSendMouseMessage(PPSendMouseMessage *pParams);
    bool OnSendMultiKeyMessage(PPSendMultiKeyMessage *pParams);
    bool OnSendMultiMouseMessage(PPSendMultiMouseMessage *pParams);

    bool InitCtrlKey();
    bool PrepareCtrlKey(HWND hWindow);
    bool PrepareKey(HWND hWindow, bool bDesire, int nKey);
    bool CleanCtrlKey();
    bool CleanKey(HWND hWindow, int nKey);

    bool DoSendKeyMessage(PPSendKeyMessage *pParams);
    bool DoSendKeyMessage(HWND hWindow, int nMsg, TCHAR nKey);
    bool DoSendMouseMessage(PPSendMouseMessage *pParams);

private:
    PPKeyState m_oKeyState;
    BYTE m_pKeyState[255];
    bool m_pKeyStateTrans[255];
};